﻿using System;
using System.Reflection;

//玩家elis引入事件
public class ElisPlayerEvent
{

    //在proc内进行引用的事件
    public static void onProc(ElisActiveObject obj)
    {

        Type procType = Type.GetType("Unity.Game.ElisAdvance.ElisScript." + ElisStateTable.getString(obj.getState()));
        if (procType != null)
        {
            MethodInfo method = procType.GetMethod("onProc");
            if (method != null)
                method.Invoke(null, new object[] { obj });
        }

    }

    public static void onSetState(ElisActiveObject obj)
    {

        
        Type procType = Type.GetType("Unity.Game.ElisAdvance.ElisScript." + ElisStateTable.getString(obj.getState()));
        if (procType != null)
        {
            MethodInfo method = procType.GetMethod("onSetState");
            if (method != null)
                method.Invoke(null, new object[] { obj });
        }
    }

    public static void onFrame(ElisActiveObject activeObject, int oldFrame)
    {
        Type procType = Type.GetType("Unity.Game.ElisAdvance.ElisScript." + ElisStateTable.getString(activeObject.getState()));
        if (procType != null)
        {
            MethodInfo method = procType.GetMethod("onFrame");
            if (method != null)
                method.Invoke(null, new object[] { activeObject,oldFrame });
        }

    }

    public static void onEndState(ElisActiveObject activeObject, State state)
    {
        Type procType = Type.GetType("Unity.Game.ElisAdvance.ElisScript." + ElisStateTable.getString(activeObject.getState()));
        if (procType != null)
        {
            MethodInfo method = procType.GetMethod("onEndState");
            if (method != null)
                method.Invoke(null, new object[] { activeObject,state });
        }
    }


}
